package com.lty.jeeg.server.modules.tms.dao;

import com.lty.jeeg.server.modules.tms.model.Project;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author : LTY
 * @date : 2019-03-26 10:52:42
 * Description : 
 */
@Mapper
@Repository
public interface ProjectDao {

    /**
     * 根据ID获取
     * @param id ID
     * @return bean
     */
    @Select("select * from tms_project t where t.id = #{id}")
    Project getById(Long id);

    /**
     * 删除
     * @param id ID
     * @return 1/0
     */
    @Delete("delete from tms_project where id = #{id}")
    int delete(Long id);

    /**
     * 修改
     * @param project ID
     * @return 1/0
     */
    int update(Project project);

    /**
     * 保存
     * @param project bean
     * @return ID
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tms_project(name, parentId, executorId, executorName, participantId, participantName, description, grade, deadline, status, classification, createBy, updateBy, isDeleted) values(#{name}, #{parentId}, #{executorId}, #{executorName}, #{participantId}, #{participantName}, #{description}, #{grade}, #{deadline}, #{status}, #{classification}, #{createBy}, #{updateBy}, #{isDeleted})")
    Long save(Project project);

    /**
     * 计数
     * @param params 筛选条件
     * @return 总数
     */
    int count(@Param("params") Map<String, Object> params);

    /**
     * 列表
     * @param params 筛选条件
     * @param offset 页码
     * @param limit 分页数目
     * @return beanList
     */
    List<Project> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
